package com.heima.search.controller.v1;

import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.model.search.vos.SearchArticleVo;
import com.heima.search.pojos.ApAssociateWords;
import com.heima.search.service.ArticleSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;


@RestController
@RequestMapping("/api/v1")
public class ArticleSearchController {

    @Resource
    private ArticleSearchService articleSearchService;

    @PostMapping("/article/search/search/")
    public ResponseResult<List<SearchArticleVo>> search(@RequestBody UserSearchDto dto) throws IOException {
        return this.articleSearchService.search(dto);
    }
    @PostMapping("/associate/search/")
    public ResponseResult<List<ApAssociateWords>> searchSuggest(@RequestBody UserSearchDto dto) throws IOException {
        return this.articleSearchService.searchSuggest(dto);
    }
}
